import QtQuick 2.15

MouseArea {
    id:root
    anchors.fill: parent
    hoverEnabled: true


    property alias interval: timer.interval
    property bool isDoubleClicked: false

    signal cusDoubleClicked()

    onDoubleClicked: { mouse.accepted = false; }
    onPositionChanged: { mouse.accepted = false; }
    onPressed:  {
        if (isDoubleClicked) {
            //console.log("onPressed: first!")
            cusDoubleClicked()
        } else {
            isDoubleClicked = true;
            timer.start()
            //console.log("onPressed: first false!")
        }
        mouse.accepted = false;
    }
    onPressAndHold: { mouse.accepted = false; }
    onClicked:  {
        mouse.accepted = false;
    }

    onReleased: {
        mouse.accepted = false;
    }
    onWheel: { wheel.accepted = false; }


    Timer {
        id: timer
        interval: 400
        repeat: false
        triggeredOnStart: false
        running: false
        onTriggered: {
            isDoubleClicked = false
        }
    }
}
